<script setup>
  import FileItemTd from './cells/FileItemTd.vue'
  import FileStatusTd from './cells/FileStatusTd.vue'
  import FileTypeTd from './cells/FileTypeTd.vue'
  import FileActionTd from './cells/FileActionTd.vue'
  import FileDateTd from './cells/FileDateTd.vue'
  import FileTemplateTd from './cells/FileTemplateTd.vue'

  const props = defineProps({
    node: Object,
    requirements: Array,
    free_files: Array,
    level: { type: Number, default: 0 },
  })
</script>
<template>
  <template v-if="requirements.length > 0">
    <tr v-for="req in requirements" :key="req.id">
      <FileStatusTd :requirement="req" :file="req.file_object" :node="node" />

      <FileTypeTd
        :file_type="req.file_type"
        :file="req.file_object"
        :requirement="req"
        :node="node"
        :level="0"
      />
      <FileItemTd :file="req.file_object" />

      <FileDateTd :file="req.file_object" />
      <FileTemplateTd :requirement="req" :file="req.file_object" :node="node" />
      <FileActionTd :requirement="req" :file="req.file_object" :node="node" />
    </tr>
  </template>
  <template v-if="free_files.length > 0">
    <tr v-for="file in free_files">
      <FileStatusTd :file="file" :node="node" />
      <FileTypeTd
        :file_type="file.file_type"
        :file="file"
        :node="node"
        :level="0"
      />
      <FileItemTd :file="file" />
      <FileDateTd :file="file" />
      <td></td>
      <FileActionTd :file="file" :node="node" />
    </tr>
  </template>
  <template v-if="free_files.length == 0 && requirements.length == 0">
    <tr>
      <FileStatusTd :node="node" />
      <td class="col_text empty" colspan="6">
        <em>Pas de fichier attaché au dossier</em>
      </td>
    </tr>
  </template>
</template>
